package com.flyduck.mall.pms.h5.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.flyduck.mall.pms.h5.service.H5CommentService;
import com.flyduck.ss.common.core.domain.R;
import com.flyduck.mall.common.web.core.BaseController;

import com.flyduck.mall.pms.h5.vo.H5CommentDetailsRespVO;
import com.flyduck.mall.pms.h5.vo.H5CommentPostReqVO;
import com.flyduck.mall.pms.h5.vo.H5CommentRespVO;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @program: vueshop
 * @description:
 * @author: flyduck
 * @create: 2024-05-23 21:37
 **/
@RestController
@RequestMapping("/h5/comment")
public class H5CommentController extends BaseController {

    @Resource
    private H5CommentService h5CommentService;

    //@Login
    @GetMapping("/getCommentPageByProductId/{productId}")
    public R<Page<H5CommentRespVO>> getCommentPageByProductId(@PathVariable("productId") Long productId){
        Page<H5CommentRespVO> appCommentRespVOPage = h5CommentService.getCommentPageByProductId(getPage(),productId);
        return R.ok(appCommentRespVOPage);
    }

    //@Login
    @GetMapping("/getCommentDetailsById/{id}")
    public R<H5CommentDetailsRespVO> getCommentDetailsById(@PathVariable("id") Long id){
        H5CommentDetailsRespVO h5CommentDetailsRespVO = h5CommentService.getCommentDetailsById(id);
        return R.ok(h5CommentDetailsRespVO);
    }

    //@Login
    @PostMapping("/postComment")
    public R<Long> postComment(MultipartFile[] pics, @Validated H5CommentPostReqVO h5CommentPostReqVO){
        Long id = h5CommentService.postComment(pics, h5CommentPostReqVO);
        return R.ok(id);
    }
}
